package com.cskaoyan.utils;

import com.cskaoyan.bean.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.Subject;

public class UserUtil {

    public static User getUser(){
        Subject subject = SecurityUtils.getSubject();
        PrincipalCollection principals = subject.getPrincipals();
        User user = null;
        if (principals != null) {
             user = (User) principals.getPrimaryPrincipal();
        }
        return user;
    }
}
